package cn.wolfcode.trip.base.domain;

import cn.wolfcode.trip.base.util.JSONUtil;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Getter;
import lombok.Setter;
import org.springframework.format.annotation.DateTimeFormat;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

@Getter
@Setter
/**
 * 游记
 */
public class Travel extends BaseDomain {
    public static final int STATE_REJECT = -1;//拒绝
    public static final int STATE_NOMAL = 0;//草稿
    public static final int STATE_WAIT = 1;//待发布
    public static final int STATE_RELEASE = 2;//已发布

    private String title;//标题

    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private Date travelTime;//出行时间

    private String perExpends;//人均消费

    private Integer days;//出行天数

    private Integer person;//随行人员

    private User author;//作者

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date createTime;//创建日期

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date releaseTime;//发布日期

    private Boolean isPublic;//是否公开

    private Region place;//地区

    private String coverUrl;//封面

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date lastUpdateTime;//最后更新时间

    private int state;//状态

    private TravelContent travelContent; //游记内容


    //获取json数据
    public String getJson() {
        Map<String, Object> map = new HashMap<>();
        map.put("id", id);
        map.put("title", title);
        map.put("coverUrl", coverUrl);
        return JSONUtil.toJSONString(map);
    }
}